package wangjg.security.resource.factory.db.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import wangjg.security.resource.factory.db.dao.ResourceDAO;
import wangjg.security.resource.factory.db.entity.Authority;
import wangjg.security.resource.factory.db.entity.Resource;

@Service
@Transactional
public class ResourceService {

	@Autowired
	private ResourceDAO dao;
	
	public List<Resource> findAll(){
		return this.dao.findAll();
	}
	
	public void initTestData(){
		Resource resource = new Resource();
		resource.setType("url");
		resource.setValue("/manage/*");
		resource.getAuthorities().add(new Authority(1, "manage"));
		dao.save(resource);
	}
}
